<template>
	<j-space>
		<tiny-alert size="mini" type="info" description="请扫描销售单。" style="width: 200px" />
    <tiny-alert size="small" text="适用场景：批量收当天 现结 客户欠款,并可同时做退货抵扣。" />
		<JInput style="margin-left: 30px; width: 220px" v-model="billNo" placeholder="二维码损坏，输入完整票号查询" @enter="doSearch" />
		<JButton @click="doSearch">搜索</JButton>
    <JCheck style="margin-left: 10px;" @changeVal="change" v-model="receiptDate" label="退货、收款时间默认填充为业务票据时间" />
	</j-space>
	<help ref="helpRef" />
</template>

<script>
import help from './help.vue'
import tool from "@/utils/tool";
export default {
  name: "top",
  components: {  help,   },
  data () {
    return {
      billNo: '',
      receiptDate: 0
    }
  },
  emits: ['doSearch', 'changeCheck'],
  created() {
    this.getReciptDate()
  },
  methods: {
    change (val) {
      tool.post('receipt/setReceiptDate', {val: val}).then(ret => {
        this.$emit('changeCheck', val)
      })
    },
    openHelp() {
      this.$refs.helpRef.open()
    },
    doSearch () {
      this.$emit('doSearch', this.billNo)
    },
    getReciptDate () {
      tool.post('receipt/getReceiptDate').then(ret => {
        if(ret.stat) {
          this.receiptDate = ret.data.receiptDate
          this.$emit('changeCheck', this.receiptDate)
        }
      })
    }
  }
};
</script>